package com.wgy.day20.类作为成员变量使用;

/**
 * Created by pc on 2020/11/17 22:24
 * Description: LearningJava
 */
//游戏英雄角色
public class Hero {
    private String name;//英雄名称
    private int age; //英雄的年龄
    private Weapon weapon;//英雄的武器

    public Hero() {
    }

    public Hero(String name, int age, Weapon weapon) {
        this.name = name;
        this.age = age;
        this.weapon = weapon;
    }

    public void attack() {
        System.out.println("年龄为"+age+"岁的"+name+"正在使用"+weapon.getCode()+"攻击敌方!");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
}
